home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / pow2.doc < prev    next >
Text File  |  1995-03-31  |  690b  |  19 lines

  1. A programming challenge, by Joseph K. Horn 
  2.  
  3. How can you tell, WITH PERFECT ACCURACY, whether or not a number is exactly a 
  4. power of 2? 
  5.  
  6. Try it:  Write a program called POW2 which tests whether the number on level 1 
  7. is a perfect power of 2, and returns a 1 if true, and a 0 if false. 
  8.  
  9. While enjoying dinner at Sizzler restaurant, a member of our local HP 
  10. Calculator Club set this challenge before us.  Everybody came up with a 
  11. different answer.  Before you look at mine (POW2 on this disk), come up 
  12. with one of your own.  There are a hundred ways to do it; which is best? 
  13.  
  14. By the way, test some difficult cases like 2^4, 2^16, and 2^39. 
  15.  
  16. Have fun! 
  17.  
  18. -jkh- 
  19.